#include "SocketException.h"

using namespace std;


SocketException::SocketException( tstring tag, int errorCode) 
: mErrorCode(errorCode)
, mErrorText(tag + _T(" ") +  getErrorText(errorCode))
{}
	
tstring SocketException::toString() {
	return mErrorText;
}

string SocketException::what() {
	return Exception::what();
}

tstring SocketException::getErrorText( DWORD errorCode) {
	TCHAR buf[512];
	int numChars = ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode,  0, buf, 512, 0);
	return to_tstring(errorCode) + _T("\n") + tstring(buf);
}
